#include <iostream>
using namespace std;


int dfs(int n,int num,int k,int *a){
	if(k == 0) return 1;
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[i] == 0) continue;
		if(num == 1) ans++;
		else{
			a[i]--;
			if(a[i] == 0)
				ans += dfs(n,num-1,k-1,a);
			else
				ans += dfs(n,num,k-1,a);
			a[i]++;
		}
	}
	return ans;
}



int main(){
	int n,num,k=0;
	cin>>n;
	num = n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		k += a[i];
		if(a[i] > 1) num++;
	}
	cout<<dfs(n,num,k,a);
	return 0;
}
